package org.nox.helloseries.web.client.metier;

import com.google.gwt.user.client.rpc.IsSerializable;

public class SerieWeb implements IsSerializable, Comparable<SerieWeb>
{
    private String nom;

    private int episode;

    private int saison;

    private VersionWeb version;

    private boolean hd;

    private boolean active;

    public SerieWeb()
    {
        this.active = true;
        this.nom = "";
        this.episode = -1;
        this.saison = -1;
        this.version = VersionWeb.VO;
        this.hd = false;
    }

    public SerieWeb( String nom, int episode, int saison, VersionWeb version, boolean hd )
    {
        super();
        this.nom = nom;
        this.episode = episode;
        this.saison = saison;
        this.version = version;
        this.hd = hd;
    }

    public SerieWeb( String nom, int episode, int saison, VersionWeb version, boolean hd, String url, int nbSeeds, String nomFichier, String infos, boolean active )
    {
        super();
        this.nom = nom;
        this.episode = episode;
        this.saison = saison;
        this.version = version;
        this.hd = hd;
        this.active = active;
    }

    public String getNom()
    {
        return nom;
    }

    public void setNom( String nom )
    {
        this.nom = nom;
    }

    public int getEpisode()
    {
        return episode;
    }

    public void setEpisode( int episode )
    {
        this.episode = episode;
    }

    public int getSaison()
    {
        return saison;
    }

    public void setSaison( int saison )
    {
        this.saison = saison;
    }

    public VersionWeb getVersion()
    {
        return version;
    }

    public void setVersion( VersionWeb version )
    {
        this.version = version;
    }

    public boolean isHd()
    {
        return hd;
    }

    public void setHd( boolean hd )
    {
        this.hd = hd;
    }

    public boolean isActive()
    {
        return active;
    }

    public void setActive( boolean active )
    {
        this.active = active;
    }

    public String toString()
    {
        String st_saison = ( getSaison() < 10 ) ? "0" + getSaison() : "" + getSaison();
        String st_episode = ( getEpisode() < 10 ) ? "0" + getEpisode() : "" + getEpisode();
        return getNom() + " S" + st_saison + "E" + st_episode + " " + version.getValue();
    }

    public int compareTo( SerieWeb s )
    {
        int result = ( this.getNom().toLowerCase().compareTo( s.getNom().toLowerCase() ) );
        if ( result == 0 )
        {
            result = Integer.valueOf( this.getSaison() ).compareTo( Integer.valueOf( s.getSaison() ) );
            if ( result == 0 )
            {
                result = Integer.valueOf( this.getEpisode() ).compareTo( Integer.valueOf( s.getEpisode() ) );
            }
        }
        return result;
    }

}
